
import { getShopManage } from "@/api/modules/user"; // login,
import storage from "@/utils/storage";
import isEqual from "lodash/isEqual";
import { Module } from "vuex"


const module: Module<any, any> = {
  namespaced: true,
  state: {
    /** 自定义店铺转发状态 */
    shopInfo: {},

    /** 自定义商品转发状态 */
    goodInfo: {},

    isTrans: {},

  },
  getters: {

  },
  mutations: {
    /**
     * @description 设置店铺信息
     * @param data 店铺信息数据
     */
    setShopInfo(state, data) {
      console.log("state", state)
      state.shopInfo = data
    },

    /**
     * @description 设置自定义商品转发信息
     * @param data 自定义商品转发信息
     */
    setGoodInfo(state, data) {
      state.goodInfo = data
    },

    setIsTrans(state, data) {
      state.isTrans = data
    }
  },
  actions: {
    /** 
     * @description 获取店铺信息
     */
    async getshopset(context) {
      const res = await getShopManage({});
      if (res && !isEqual(res, storage.get("getshopsetData"))) {
        storage.set("getshopsetData", res, 3 * 24 * 60 * 60 * 1000);
      }
      context.commit('setShopInfo', res)
    },
  }
}

export default module;
